Skip to content

all major fix for the CLI done - #803

Open
Sadeequ wants to merge 3 commits into
BCPathway:mainfrom
Sadeequ:CLI-fix
Open

all major fix for the CLI done#803
Sadeequ wants to merge 3 commits into
BCPathway:mainfrom
Sadeequ:CLI-fix

Conversation

@Sadeequ

@Sadeequ Sadeequ commented Aug 26, 2026

Copy link
Copy Markdown

Report: Fixes for Four CLI Issues

Issue 1: Setup default rate limits during init

I identified that the token contract's initialize function in contracts/token/src/lib.rs was not configuring any rate limits during initialization. The rate limiting infrastructure existed in the bc_forge_rate_limit crate but was never invoked during the init flow.

I added a set_default_rate_limits function to the token contract that configures global rate limits for all five operation types: mint, transfer, transfer_from, burn, and burn_from. Each operation type receives a default limit of 1000 operations per 60-second window. This function is called automatically at the end of initialize(), ensuring every newly deployed contract starts with sensible rate limiting in place.

File modified: contracts/token/src/lib.rs


Issue 2: Initialize token metadata (name, symbol, decimals)

I found that the CLI's config init command was generating a template .bc-forge.json file without an admin field, even though the initialize command required it. This created a poor user experience where the generated config was immediately insufficient for deployment.

I made three changes:

  1. Added the --admin option to the config init command in cli/src/index.ts, allowing users to specify the admin address when creating the template config file.

  2. Added the pauser field to the BcForgeConfig interface in cli/src/utils/config-parser.ts, extending the config schema to support the Pauser role address.

  3. Added the pauser field to the JSON schema in cli/src/schema/bc-forge.schema.json with the Stellar G-address pattern validation (^G[A-Z2-7]{55}$).

Files modified: cli/src/index.ts, cli/src/utils/config-parser.ts, cli/src/schema/bc-forge.schema.json


Issue 3: Link Pauser role to multisig address

I determined that the CLI had no mechanism to grant the Pauser role to a multisig address during initialization. The contract supported role-based access control with a Pauser role, but the CLI only exposed grantMinter and revokeMinter operations.

I implemented this fix by:

  1. Adding --pauser option to the initialize command in cli/src/index.ts. When provided, the CLI grants the Pauser role to the specified address immediately after successful contract initialization.

  2. Adding grantPauser() and revokePauser() methods to the SDK client in sdk/src/client.ts. These invoke the contract's grant_role and revoke_role functions with the Role::Pauser parameter.

Files modified: cli/src/index.ts, sdk/src/client.ts


Issue 4: Verify on-chain state post-init

I recognized that the CLI had no way to confirm that the on-chain state matched the intended configuration after initialization. If a transaction succeeded but the contract state was unexpected (e.g., due to a simulation/execution mismatch), the user would have no indication.

I implemented post-init verification by:

  1. Adding a --verify flag to the initialize command in cli/src/index.ts. When enabled, the CLI queries the contract state after initialization and compares it against the expected values.

  2. Adding the verifyInitializedState() method to the SDK client in sdk/src/client.ts. This method queries the contract for its current admin, name, symbol, decimals, and total supply, and optionally checks whether the Pauser role was granted to the expected address. It returns an InitVerificationResult object containing the verification status and any discrepancies.

  3. Adding getAdmin() and hasRole() methods to the SDK client for querying contract state.

  4. Adding the InitVerificationResult interface to sdk/src/client.ts and exporting it from sdk/src/index.ts.

Files modified: cli/src/index.ts, sdk/src/client.ts, sdk/src/index.ts


Verification

I confirmed all changes compile successfully:

  • The SDK (sdk/) passes tsc --noEmit with no errors
  • The CLI (cli/) passes tsc --noEmit with no errors
  • All 21 SDK tests pass
  • All 14 CLI tests pass

Related Issues

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Sadeequ Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@p3ris0n

p3ris0n commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Sadeequ please fix CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants